﻿namespace Samples.Explorer.Controllers.Explorer
{
    using System.Linq;
    using System.Web.Hosting;
    using System.Web.Mvc;

    public class ExplorerController : Controller
    {
        [HttpGet]
        public ActionResult Index(string virtualPath = "/", EntrySource filter = EntrySource.Merged)
        {
            var virtualDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory(virtualPath);
            var model = DirectoryView.Create(virtualDirectory, filter, v => this.Url.Action("index", "explorer", new { virtualPath = v, filter = filter }));

            return this.View(model);
        }
    }
}
